﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="XinNghiPhep.aspx.cs" Inherits="ChamCong.NhanVien.XinNghiPhep" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <!--Calendar Script-->
    <link type="text/css" rel="stylesheet" href="../Scripts/JSCal/css/jscal.css" />
    <link type="text/css" rel="stylesheet" href="../Scripts/JSCal/css/border-radius.css" />
    <script type="text/javascript" src="../Scripts/JSCal/js/jscal2.js"></script>
    <script type="text/javascript" src="../Scripts/JSCal/js/lang/vn.js"></script>
    <!--End Calendar-->
    <script type="text/javascript">
        function NghiCoLuong() {
            document.getElementById('divNghiCoLuong').style.display = 'block';
        }
        function NghiKhongLuong() {
            document.getElementById('divNghiCoLuong').style.display = 'none';
        }
        function NghiNhieuNgay() {
            document.getElementById('divNghiCoLuong').style.display = 'block';
        }
        function NghiMotNgay() {
            document.getElementById('divNghiCoLuong').style.display = 'none';
        }
        //        function is_int() {
        //            var value = document.getElementById("<%=tbxNgayNghiCoLuong.ClientID %>").value;
        //            if ((parseFloat(value) == parseInt(value)) && !isNaN(value)) {
        //                return true;
        //            } else {
        //                alert("Số ngày nghỉ có lương phải là số nguyên.");
        //                return false;
        //            }
        //        }

        function checkDateDenNgay(sender, args) {
            var toDate = new Date();
            toDate.setMinutes(0);
            toDate.setSeconds(0);
            toDate.setHours(0);
            toDate.setMilliseconds(0);

            var tuNgay = new Date(document.getElementById("<%=tbxTuNgay.ClientID %>").value);
            tuNgay.setMinutes(0);
            tuNgay.setSeconds(0);
            tuNgay.setHours(0);
            tuNgay.setMilliseconds(0);
            //var msDateA = Date.UTC(tuNgay.getFullYear(), tuNgay.getMonth() + 1, tuNgay.getDate());
            if (sender._selectedDate > tuNgay) {
                if (sender._selectedDate < toDate) {
                    alert("Ngày nghỉ phải lớn hơn hoặc bằng ngày hiện tại!");
                    sender._selectedDate = toDate;
                    //set the date back to the current date
                    sender._textbox.set_Value(sender._selectedDate.format(sender._format))
                }
            }
            else {
                alert("Đến ngày phải lớn hơn Từ ngày!");
                //sender._selectedDate = tuNgay;
                //sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }

        }


    </script>
    <style type="text/css">
        #tknangcao i:hover
        {
            color: red;
        }
        
        .style5
        {
            text-align: center;
        }
        .style6
        {
            height: 40px;
        }
        .style7
        {
            height: 24px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager2" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" CssClass="childMenu"
            SkipLinkText="">
            <Items>
                <asp:MenuItem Text="Xin nghỉ phép" Value="" NavigateUrl="~/NhanVien/XinNghiPhep.aspx">
                </asp:MenuItem>
                <asp:MenuItem Text="Phép chờ duyệt" Value="" NavigateUrl="~/NhanVien/XinNghiPhep.aspx?ttd=0">
                </asp:MenuItem>
                <asp:MenuItem Text="Phép đã duyệt" Value="" NavigateUrl="~/NhanVien/XinNghiPhep.aspx?ttd=1">
                </asp:MenuItem>
                <asp:MenuItem Text="Phép không duyệt" Value="" NavigateUrl="~/NhanVien/XinNghiPhep.aspx?ttd=2">
                </asp:MenuItem>
            </Items>
        </asp:Menu>
    </div>
    <div>
        <asp:Panel ID="pnlXinNghiPhep" runat="server" Visible="False">
            <table align="center" cellpadding="2" cellspacing="3" class="style1">
                <tr>
                    <td align="left" colspan="2">
                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                            <ContentTemplate>
                                <sbc:sbcMsgBox ID="sbcMsgBox1" runat="server" UseJQuery="True" />
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Họ tên nhân viên</b>
                    </td>
                    <td>
                        <asp:Label ID="lblTenNV" runat="server" Text="lblTenNV"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Mã số nhân viên</b>
                    </td>
                    <td>
                        <asp:Label ID="lblMaNV" runat="server" Text="lblMaNV"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Số điện thoại</b>
                    </td>
                    <td>
                        <asp:Label ID="lblSoDienThoai" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Phòng ban</b>
                    </td>
                    <td>
                        <asp:Label ID="lblPhongBan" runat="server"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Loại nghỉ phép</b>
                    </td>
                    <td>
                        <asp:DropDownList class="dropdownlist" ID="ddlLoaiNghiPhep" runat="server" DataSourceID="DSLoaiPhep"
                            DataTextField="TenLoaiPhep" DataValueField="MaLoaiPhep">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="DSLoaiPhep" runat="server" SelectMethod="LayTatCa" TypeName="BusinessLogicLayer.LoaiPhepBLL">
                        </asp:ObjectDataSource>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:RadioButtonList ID="RadioButtonList2" runat="server" RepeatDirection="Horizontal"
                            Style="text-align: left" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList2_SelectedIndexChanged">
                            <asp:ListItem Selected="True" Value="1">Nghỉ một ngày</asp:ListItem>
                            <asp:ListItem Value="2">Nghỉ nhiều ngày</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <asp:Panel ID="pnlNghiMotNgay" runat="server">
                    <tr>
                        <td>
                            <b>Ngày nghỉ:</b>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlNgay" runat="server">
                                <asp:ListItem Value="3">Ngày</asp:ListItem>
                                <asp:ListItem Value="1">Sáng</asp:ListItem>
                                <asp:ListItem Value="2">Chiều</asp:ListItem>
                            </asp:DropDownList>
                            <asp:TextBox ID="tbxNgayNghi" runat="server" onblur="checkDate()"></asp:TextBox>
                            <script type="text/javascript">

                                Cal = new Calendar({
                                    inputField: "tbxNgayNghi",
                                    dateFormat: "%d-%m-%Y",
                                    trigger: "tbxNgayNghi",
                                    bottomBar: false,
                                    onSelect: function () { this.hide(); }

                                });
                                Cal.setup({ max: now });
                            </script>
                        </td>
                    </tr>
                </asp:Panel>
                <asp:Panel ID="pnlNghiNhieuNgay" runat="server" Visible="False">
                    <tr>
                        <td>
                            <b>Từ:</b>
                        </td>
                        <td>
                            <div>
                                <asp:DropDownList ID="ddlTuNgay" runat="server">
                                    <asp:ListItem Value="3">Ngày</asp:ListItem>
                                    <asp:ListItem Value="0">Sáng</asp:ListItem>
                                    <asp:ListItem Value="1">Chiều</asp:ListItem>
                                </asp:DropDownList>
                                <asp:TextBox ID="tbxTuNgay" runat="server"></asp:TextBox>
                                <script type="text/javascript">
                                    Cal = new Calendar({
                                        inputField: "tbxTuNgay",
                                        dateFormat: "%d-%m-%Y",
                                        trigger: "tbxTuNgay",
                                        bottomBar: false,
                                        onSelect: function () { this.hide(); }
                                    });
                                </script>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Đến:</b>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlDenNgay" runat="server">
                                <asp:ListItem Value="4">Ngày</asp:ListItem>
                                <asp:ListItem Value="0">Sáng</asp:ListItem>
                                <asp:ListItem Value="1">Chiều</asp:ListItem>
                            </asp:DropDownList>
                            <asp:TextBox ID="tbxDenNgay" runat="server"></asp:TextBox>
                            <script type="text/javascript">
                                Cal = new Calendar({
                                    inputField: "tbxDenNgay",
                                    dateFormat: "%d-%m-%Y",
                                    trigger: "tbxDenNgay",
                                    bottomBar: false,
                                    onSelect: function () { this.hide(); }
                                });
                            </script>
                            <br />
                            <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="End time should be greater than Start" ClientValidationFunction="compareTime" ControlToValidate="tbxDenNgay"></asp:CustomValidator>--%>
                        </td>
                    </tr>
                </asp:Panel>
                <tr>
                    <td>
                        <strong>Tính ngày nghỉ</strong>
                    </td>
                    <td>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <asp:CheckBox ID="cbxTinhNgay" runat="server" />
                                <asp:Label ID="lblThongTin" runat="server" Font-Bold="True" ForeColor="#CC0000" Width="300px"></asp:Label>
                                <asp:TextBox ID="tbxSoNgayNghi" runat="server" Visible="False"></asp:TextBox>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="style7">
                        Bạn còn
                        <asp:Label ID="lblNgayNghiThuongNien2" runat="server"></asp:Label>
                        &nbsp;ngày nghỉ thường niên.<br />
                    </td>
                </tr>
                <tr>
                    <td class="style6">
                        <strong>Hình thức nghỉ</strong>
                    </td>
                    <td class="style6">
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="25px" RepeatDirection="Horizontal">
                            <asp:ListItem Value="1" onclick="javascript:NghiCoLuong();">Nghỉ có lương</asp:ListItem>
                            <asp:ListItem Value="0" onclick="javascript:NghiKhongLuong();" Selected="True">Nghỉ không lương</asp:ListItem>
                        </asp:RadioButtonList>
                        <div id="divNghiCoLuong" style="display: none;">
                            <asp:Label ID="Label1" runat="server" Text="Nhập vào số ngày nghỉ có lương " Font-Italic="True"></asp:Label>
                            <asp:TextBox ID="tbxNgayNghiCoLuong" runat="server" Width="25px"></asp:TextBox>
                            <asp:Label ID="Label2" runat="server" Text="/"></asp:Label>
                            <asp:Label ID="lblNgayNghiThuongNien" runat="server" Font-Bold="True" Font-Size="Small"
                                ForeColor="#CC0000"></asp:Label>
                            <br />
                            (Ví dụ: 1 hoặc 1.5)
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Lý do</b>
                    </td>
                    <td>
                        <asp:TextBox ID="tbxLyDo" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="style5">
                        <asp:Button class="button" ID="btnNopDon" runat="server" OnClick="btnNopDon_Click"
                            Text="Nộp đơn" />
                        <asp:Button class="button" ID="btnHuyBo" runat="server" Text="Hủy bỏ" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <div style="display: none;">
                            <asp:Button class="button" ID="btnTextBoxEventHandler" runat="server" OnClick="btnTextBoxEventHandler_Click" />
                        </div>
                        <div>
                            <sbc:sbcMsgBox ID="sbcMsgBox3" runat="server" UseJQuery="True" />
                        </div>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
    <div style="float: left; width: 500px">
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
                <asp:GridView ID="dgvDSPhepDaXin" runat="server" AutoGenerateColumns="False" CellPadding="4"
                    ForeColor="#333333" GridLines="None" 
                    OnRowDataBound="dgvPhepDaXin_rowdatabound" AllowPaging="True" PageSize="8" 
                    onpageindexchanging="dgvPhepDaXin_PageIndexChange">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="MaPhep" HeaderText="Mã ĐXP" SortExpression="MaPhep" />
                        <asp:TemplateField HeaderText="Từ Ngày">
                            <ItemTemplate>
                                <asp:Label ID="lblTuNgay" runat="server" Text='<%#AutoConvert(Eval("TuNgay"))%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Đến Ngày">
                            <ItemTemplate>
                                <asp:Label ID="lblTuNgay" runat="server" Text='<%#AutoConvert(Eval("DenNgay"))%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="SoBuoiNghi" HeaderText="Số ngày nghỉ" />
                        <asp:TemplateField HeaderText="Trạng thái">
                            <ItemTemplate>
                                <asp:Label ID="lblTrangThaiDuyet" runat="server" Text='<%# ktDuyet(Eval("TrangThaiDuyet")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="TrangThaiDoc" HeaderText="TTD" Visible="false"></asp:BoundField>
                        <asp:TemplateField HeaderText="Xem">
                            <ItemTemplate>
                                <a href='XinNghiPhep.aspx?ttd=<%# LayLoaiDS() %>&MaPhep=<%# Eval("MaPhep") %>'>Xem</a>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" CssClass="pager" />
                    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                    <SortedAscendingCellStyle BackColor="#FDF5AC" />
                    <SortedAscendingHeaderStyle BackColor="#4D0000" />
                    <SortedDescendingCellStyle BackColor="#FCF6C0" />
                    <SortedDescendingHeaderStyle BackColor="#820000" />
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <sbc:sbcMsgBox ID="sbcMsgBox2" runat="server" UseJQuery="True" />
    </div>
    <div style="float: left; width: 350px;">
        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
                <asp:DetailsView ID="dtvChiTietDXP" runat="server" Height="50px" Width="320px" Visible="False"
                    AutoGenerateRows="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px"
                    CellPadding="2" ForeColor="Black" GridLines="None">
                    <AlternatingRowStyle BackColor="PaleGoldenrod" />
                    <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                    <Fields>
                        <asp:BoundField DataField="MaPhep" HeaderText="Mã phép" />
                        <asp:TemplateField HeaderText="Tên nhân viên">
                            <ItemTemplate>
                                <asp:Label ID="lblTenNV" runat="server" Text='<%# ktTenNV(Eval("MaNV")) %>' Font-Bold="True"
                                    ForeColor="#CC0000"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Loại phép">
                            <ItemTemplate>
                                <asp:Label ID="lblLoaiPhep" runat="server" Text='<%# ktLoaiPhep(Eval("MaLoaiPhep")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Từ">
                            <ItemTemplate>
                                <asp:Label ID="lblTuNgay" runat="server" Text='<%# Eval("TuNgay","{0:dd/MM/yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Đến">
                            <ItemTemplate>
                                <asp:Label ID="lblDenNgay" runat="server" Text='<%# Eval("DenNgay","{0:dd/MM/yyyy}") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thông tin nghỉ">
                            <ItemTemplate>
                                <asp:Label ID="lblLoaiBuoi" runat="server" Text='<%# ktThongTinBuoi(Eval("LoaiBuoi")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="SoNgayNghi" HeaderText="Số ngày nghỉ" />
                        <asp:BoundField DataField="SoNgayNghiCoLuong" HeaderText="Số ngày nghỉ có lương" />
                        <asp:BoundField DataField="LyDo" HeaderText="Lý do" />
                        <asp:BoundField DataField="NgayTao" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Ngày nộp" />
                        <asp:TemplateField HeaderText="Trạng thái">
                            <ItemTemplate>
                                <asp:Label ID="lblTrangThaiDuyet" runat="server" Text='<%# ktDuyet(Eval("TrangThaiDuyet")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                    <FooterStyle BackColor="Tan" />
                    <HeaderStyle BackColor="Tan" Font-Bold="True" />
                    <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                </asp:DetailsView>
                <br />
                <div>
                    <asp:Label ID="lblChuThich" runat="server" Text="Phản hồi" Visible="False" Font-Bold="True"
                        Font-Italic="True" ForeColor="#CC3300"></asp:Label>
                </div>
                <div>
                    <asp:TextBox ID="tbxChuThich" runat="server" Height="71px" TextMode="MultiLine" Width="320px"
                        Visible="False" Enabled="False" BorderStyle="Dashed" Font-Bold="True"></asp:TextBox>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
